<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="./static/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="./static/admin/css/admin.css"/>
			            
	    <script type="text/javascript" src="./static/js/jquery-1.12.4.js"></script>
	    <script type="text/javascript" src="./static/js/my.js"></script>
	</head>
	<body>
	<form class="layui-form column-content-detail">
					<div class="layui-tab">
						<ul class="layui-tab-title">
							<li class="layui-this">网站添加</li>
						</ul>
						<div class="layui-tab-content">
							<div class="layui-tab-item layui-show">
								<div class="layui-form-item">
									<label class="layui-form-label">监控项名字：</label>
									<div class="layui-input-block">
										<input type="text" name="name" required lay-verify="required" placeholder="请输入监控项名字" autocomplete="off" class="layui-input">
									</div>
								</div>

								<div class="layui-form-item">
									<label class="layui-form-label">URL：</label>
									<div class="layui-input-block">
										<input type="text" name="url" required lay-verify="required" placeholder="请输入URL" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">是否启用：</label>
									<div class="layui-input-block">
										<input type="checkbox" name="is_enable" lay-skin="switch">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">访问间隔：</label>
									<div class="layui-input-block">
										<select name="interval" lay-verify="required">
											<option value="5" selected="selected">5分钟</option>
											<option value="10">10分钟</option>
											<option value="15">15分钟</option>
										</select>
									</div>
								</div>

							</div>

						</div>
					</div>
					<div class="layui-form-item" style="padding-left: 10px;">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="site-add">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
	<script src="./static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="./static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" src="./static/js/jquery-1.12.4.js"></script>

	<script>
		layui.use(['form', 'element'], function () {
			var form = layui.form();
			var element = layui.element();
			form.render();
			form.on('submit(site-add)', function(data) {
				// layer.msg(JSON.stringify(data.field));
				$.ajax(
						{
							url: '/api/website',
							type: 'PUT',
							data: JSON.stringify(data.field),
							xhrFields: {
								withCredentials: true
							},
							success: function (obj) {

								if (obj.code == 20) {
									alert("更新成功了，页面会重新加载");
									// layer.msg("更新成功", {time: 3});
									// time.sleep(3);
									// $(location).attr('href', 'index.html');
									location.reload();
								} else {
									alert(obj.msg);
								}
							},
							error: function (obj) {
								alert('未知错误');
							}
						}
				);
				return false;
			});
		});

	</script>
	</body>
</html>